-- Picture Table Changes
ALTER TABLE [Picture] DROP COLUMN Category_ID
GO
ALTER TABLE [Picture] ADD IsListing Bit
GO
ALTER TABLE [Picture] ADD IsFavorite Bit
GO
ALTER TABLE [Picture] ADD IsRegionListingImage Bit
GO
ALTER TABLE [Picture] ADD IsStateListingImage Bit
GO
ALTER TABLE [Picture] ADD IsDecadeListingImage Bit
GO
ALTER TABLE [Picture] ADD IsHardenListingImage Bit
GO
ALTER TABLE [Picture] ADD IsRyanListingImage Bit
GO
ALTER TABLE [Picture] ADD IsFriendListingImage Bit
GO

UPDATE Picture SET IsListing = 1
FROM Picture p INNER JOIN PictureListing pl ON p.Picture_ID = pl.Picture_ID

INSERT INTO Picture (Picture_ID, Picture_code, Event_ID, Picture_ImagePath, IsListing, Date_Created, Date_Modified)
	SELECT newid(), p2.picture_code, e.Event_ID, p2.Picture_ImagePath, 1, GETDATE(), GETDATE() FROM EVENT e
	LEFT JOIN picture p ON e.event_id = p.event_id
	LEFT JOIN picturelisting pl ON e.event_id = pl.event_id
	LEFT JOIN picture p2 ON pl.picture_id = p2.picture_id
	WHERE p.event_id IS NULL AND p2.Picture_ImagePath IS NOT NULL 

UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 23
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 63
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 65
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 75
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 93
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 101
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 123
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 124
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 170
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 287
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 372
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 394
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 415
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 569
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 570
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 571
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 572
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 596
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 613
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 630
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 631
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 634
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 648
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 649
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 662
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 672
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 719
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 756
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 768
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1258
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1369
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1370
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1376
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1415
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1424
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1771
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1793
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1892
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1912
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1921
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1925
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1954
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1959
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 1986
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2005
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2019
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2180
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2198
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2405
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2414
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2416
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2468
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2473
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2474
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2482
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2611
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2740
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2789
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2800
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2845
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2854
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2875
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2881
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2908
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2921
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2938
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 2954
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3020
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3025
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3056
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3065
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3066
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3143
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3312
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3370
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3408
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3481
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3484
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3667
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3856
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 3882
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4017
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4204
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4205
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4238
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4354
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4355
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4371
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4447
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4448
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4450
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4493
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4502
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4504
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4539
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4544
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4573
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4755
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4757
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4758
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4815
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4830
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4851
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4878
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4891
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4897
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 4990
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 5156
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 5295
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 5712
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 5740
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 5760
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 5767
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6027
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6723
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6741
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6767
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6986
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6987
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6990
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6998
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 6999
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7012
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7038
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7042
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7045
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7046
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7113
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7140
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7150
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7155
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7165
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7170
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7172
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7181
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7187
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7188
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7204
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7310
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7328
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7329
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7330
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7368
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7369
UPDATE Picture SET IsFavorite = 1 WHERE Picture_code = 7399